﻿using Dogshow.Model.Extensions;
using Dogshow.Model.Validation;
using FluentValidation.Attributes;

namespace Dogshow.Model
{
    [Validator(typeof(KinoloskoDrustvoValidator))]
    public class KinoloskoDrustvo : Entity
    {
        public int Id { get; set; }
        private string m_Naziv;
        public string Naziv
        {
            get { return m_Naziv; }
            set
            {
                if (Naziv != value)
                {
                    m_Naziv = value.TrimNullAndToUpper();
                    OnPropertyChanged("Naziv");
                }
            }
        }

        private string m_Telefon;
        public string Telefon
        {
            get { return m_Telefon; }
            set
            {
                if (Telefon != value)
                {
                    m_Telefon = value;
                    OnPropertyChanged("Telefon");
                }
            }
        }

        private string m_Faks;
        public string Faks
        {
            get { return m_Faks; }
            set
            {
                if (Faks != value)
                {
                    m_Faks = value;
                    OnPropertyChanged("Faks");
                }
            }
        }

        private string m_EMail;
        public string EMail
        {
            get { return m_EMail; }
            set
            {
                if (EMail != value)
                {
                    m_EMail = value;
                    OnPropertyChanged("EMail");
                }
            }
        }

        private string m_TekuciRacun;
        public string TekuciRacun
        {
            get { return m_TekuciRacun; }
            set
            {
                if (TekuciRacun != value)
                {
                    m_TekuciRacun = value;
                    OnPropertyChanged("TekuciRacun");
                }
            }
        }

        private string m_Adresa;
        public string Adresa
        {
            get { return m_Adresa; }
            set
            {
                if (Adresa != value)
                {
                    m_Adresa = value.TrimNullAndToSentence();
                    OnPropertyChanged("Adresa");
                }
            }
        }

        private int? m_IdMesta;
        public int? IdMesta
        {
            get { return m_IdMesta; }
            set
            {
                if (IdMesta != value)
                {
                    m_IdMesta = value;
                    OnPropertyChanged("IdMesta");
                }
            }
        }

        private Mesto m_Mesto;
        public Mesto Mesto
        {
            get { return m_Mesto; }
            set
            {
                if (Mesto != value)
                {
                    m_Mesto = value;
                    OnPropertyChanged("Mesto");
                }
            }
        }

        public override string ToString()
        {
            return string.Format("{0} {1}", Naziv, Mesto.Naziv);
        }

        public override void FixForeignKeys()
        {
            if (Mesto != null)
            {
                IdMesta = Mesto.Id;
            }
        }
    }
}